#include <cstdio>


// Define a simple struct type
struct Point
{
    float x;
    float y;
    float z;
};

// CUDA kernel that takes a struct as an argument
__global__ void myKernel(Point *p)
{
    int i = threadIdx.x;
    p[i].x += 1.0f;
    p[i].y += 2.0f;
    p[i].z += 3.0f;
}

int main()
{
    Point *d_points;
    cudaMalloc(&d_points, sizeof(Point) * 4);

    Point h_points[4] = {{0, 0, 0}, {1, 1, 1}, {2, 2, 2}, {3, 3, 3}};
    cudaMemcpy(d_points, h_points, sizeof(Point) * 4, cudaMemcpyHostToDevice);

    myKernel<<<1, 4>>>(d_points);

    cudaMemcpy(h_points, d_points, sizeof(Point) * 4, cudaMemcpyDeviceToHost);

    for (int i = 0; i < 4; i++)
    {
        printf("Point %d: (%f, %f, %f)\n", i, h_points[i].x, h_points[i].y, h_points[i].z);
    }

    cudaFree(d_points);

    return 0;
}